<?php

namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Http\Resources\ServiceResource;
use App\Models\Cases;
use Illuminate\Http\Request;

class CasesController extends Controller
{
    public function index(Request $request)
    {
        $resources = Cases::select('id', 'title', 'service', 'company', 'image', 'published_at')
            ->latest('orderby')
            ->latest('id')
            ->paginate(request()->per_page ?? 10);

        return new ServiceResource($resources);
    }

    public function show(Cases $case)
    {
        $case->increment('readnum');
        return $this->successful($case);
    }
}
